<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/ISupplierAccessDao.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IConnectionAccessDao.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/ConnectionFactory.php';

	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];

  class   MySqlSupplierAccessDao implements ISupplierAccessDao {
  
 	 	/**
		 * Constructor
		 */
	 public function __construct () {}
	 
  
     public function createSupplier  ($pk_Rif,$name) {
		 
		$connection = ConnectionFactory::getMySqlConnectionAccessDao();
		$conn=$connection->openConnection();
		$conn = mysql_connect("localhost", "root", "");
		mysql_select_db("sager", $conn);	
		 
		 $query = "INSERT INTO SUPPLIER
		           VALUES ('$pk_Rif','$name')";
	 
	 
	 
	    $sentence=mysql_query($query,$conn);
	       if ($sentence){
			    return true;
			   }
		  return false;
	 
	 }
	 
	 public function changeSupplier  ($pk_Rif,$name)
	 {
	    $connection = ConnectionFactory::getMySqlConnectionAccessDao();
		$conn=$connection->openConnection();
		$conn = mysql_connect("localhost", "root", "");
		mysql_select_db("sager", $conn);
		
		$query = "UPDATE SUPPLIER SET pk_Rif='$pk_Rif',name='$name'";
	 
	 
	 
	    $sentence=mysql_query($query,$conn);
	       if ($sentence){
			    return true;
			   }
		  return false;
	 
	 }
	 

  
  }


?>